package cn.cxq.learning.divide_and_conquer;

/**
 * 汉诺塔问题
 */
public class HanoiTower {

    private static int step = 0;

    public static int hanoiTower(int num, char a, char b, char c) {

        if (num == 0) return 0;

        if (num == 1) {
            System.out.println("第 " + String.format("%03d",++step) + " 步从 " + a + " 到 " + c + " ；");
        } else {
            hanoiTower(num - 1, a, c, b);
            System.out.println("第 " + String.format("%03d",++step) + " 步从 " + a + " 到 " + c + " ；");
            hanoiTower(num - 1, b, a, c);
        }
        return step;
    }
}
